home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////////////////////////// //
- //
- // DeviceRegistry.cxx
- //
- // This class keeps up with a list of all of the availible devices and
- // allocates them. It's derived from the BasicDeviceRegistry
- //
- // By: Bradford W. Mott
- // October 30,1993
- //
- ///////////////////////////////////////////////////////////////////////////////
-
- #include <iostream.h>
- #include "DeviceRegistry.hxx"
- #include "RAM.hxx"
-
- ///////////////////////////////////////////////////////////////////////////////
- // Array of device information (name, description, tcl script)
- ///////////////////////////////////////////////////////////////////////////////
- const DeviceInformation DeviceRegistry::device_info[] = {
- {"RAM",
- "Random Access Memory",
- #include "RAM.scr"
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////////
- // The Constructor
- ///////////////////////////////////////////////////////////////////////////////
- DeviceRegistry::DeviceRegistry()
- : BasicDeviceRegistry(device_info,
- sizeof(device_info)/sizeof(DeviceInformation))
- {}
-
- ///////////////////////////////////////////////////////////////////////////////
- // Create a device with the given name (return 1=OK,0=ERROR)
- ///////////////////////////////////////////////////////////////////////////////
- int DeviceRegistry::Create(String& name, String& args, BasicCPU *cpu,
- BasicDevice* &device)
- {
- if (name=="RAM")
- device=new RAM(args, cpu);
- else
- return(0);
-
- // If the device's error message is not empty then return error
- if(device->GetErrorMessage()!="")
- {
- delete device;
- return(0);
- }
-
- return(1);
- }
-
-